﻿using System.Reflection;

namespace System.Windows.Data
{
    public static class ConverterExtension
    {
        static ConverterExtension()
        {
            if (disconnectedItem == null)
                disconnectedItem = typeof(System.Windows.Data.BindingExpressionBase)
                    .GetField("DisconnectedItem", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
        }

        private static object disconnectedItem = null;

        public static bool IsValidValue(this IMultiValueConverter obj, object value)
        {
            return value != disconnectedItem && value != DependencyProperty.UnsetValue;
        }
    }
}